type SetInitialState = (initialState: any) => void;

export const updateInitialState = (newState: any, setInitialState: SetInitialState) => {
  try {
    // 只存储用户信息
    localStorage.setItem('user_info', JSON.stringify(newState.currentUser));

    // 更新全局状态
    setInitialState((s: any) => ({
      ...s,
      ...newState,
    }));

    console.log('状态更新成功:', newState);
    return true;
  } catch (error) {
    console.error('状态更新失败:', error);
    return false;
  }
};
